﻿package mortal.game.resource
{
    import com.gengine.resource.*;
    import com.gengine.utils.*;
    import flash.utils.*;
    import mortal.game.resource.info.*;

    public class ColorConfig extends Object
    {
        private var _dataColor:Dictionary;
        private static var _instance:ColorConfig;

        public function ColorConfig(param1:ConstructorBlock)
        {
            this._dataColor = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" ColorConfig 单例 ");
            }
            _instance = this;
            this.parseColorXML(ConfigManager.instance.getObjectByFileName("color.xml"));
            return;
        }// end function

        private function parseColorXML(param1:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_4:String = null;
            var _loc_5:Object = null;
            var _loc_6:ColorInfo = null;
            var _loc_2:* = param1.items as Array;
            for each (_loc_3 in _loc_2)
            {
                
                _loc_4 = _loc_3.type.toString();
                for each (_loc_5 in _loc_3.item as Array)
                {
                    
                    _loc_6 = new ColorInfo();
                    _loc_6.type = StringHelper.getString(_loc_4);
                    _loc_6.color = StringHelper.getString(_loc_5.value);
                    _loc_6.id = StringHelper.getString(_loc_5.id);
                    _loc_6.colorText = StringHelper.getString(_loc_5.text);
                    this.addItem(_loc_6);
                }
            }
            return;
        }// end function

        public function addItem(param1:ColorInfo) : void
        {
            this._dataColor[param1.type + "-" + param1.id] = param1;
            return;
        }// end function

        public function getItem(param1:String, param2:String) : ColorInfo
        {
            return this._dataColor[param1 + "-" + param2] as ColorInfo;
        }// end function

        public function getItemColor(param1:int) : ColorInfo
        {
            return this._dataColor["item" + "-" + param1];
        }// end function

        public function getRumorColor(param1:int) : ColorInfo
        {
            return this._dataColor["rumor" + "-" + param1];
        }// end function

        public function getItemColorString(param1:int) : String
        {
            var _loc_2:String = "";
            var _loc_3:* = this.getItemColor(param1);
            if (_loc_3)
            {
                _loc_2 = _loc_3.color;
            }
            return _loc_2;
        }// end function

        public function getCampColor(param1:int) : ColorInfo
        {
            return this._dataColor["country" + "-" + param1];
        }// end function

        public function getCountryColor(param1:int) : ColorInfo
        {
            var _loc_2:* = this._dataColor["country" + "-" + param1];
            if (!_loc_2)
            {
                _loc_2 = this._dataColor["country-0"];
            }
            return _loc_2;
        }// end function

        public function getCareerColor(param1:int) : ColorInfo
        {
            var _loc_2:* = this._dataColor["career" + "-" + param1];
            if (!_loc_2)
            {
                _loc_2 = this._dataColor["career-0"];
            }
            return _loc_2;
        }// end function

        public function getChatColor(param1:String) : ColorInfo
        {
            return this._dataColor["chat" + "-" + param1];
        }// end function

        public function getCoinColor(param1:int) : ColorInfo
        {
            return this._dataColor["coin" + "-" + param1];
        }// end function

        public function getGoldColor(param1:int) : ColorInfo
        {
            return this._dataColor["gold" + "-" + param1];
        }// end function

        public static function get instance() : ColorConfig
        {
            if (_instance == null)
            {
                _instance = new ColorConfig(new ConstructorBlock());
            }
            return _instance;
        }// end function

    }
}

class ConstructorBlock extends Object
{

    function ConstructorBlock()
    {
        return;
    }// end function

}

